<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
        <title>Document</title>
        <script>
            var arr1 = [10, 20, 30, 40, 50];
            var arr2 = [1, 2, 3, 4, 5];


            /* 
                想要给数组添加一个方法，可以对数组中每一个元素进行求和
            */
            arr1.sum = function(){
                var res = 0;
                for(var i = 0; i < this.length; i++){
                    res += this[i];
                }
                return res;
            }

            arr2.sum = function(){
                var res = 0;
                for(var i = 0; i < this.length; i++){
                    res += this[i];
                }
                return res;
            }



            alert(arr1.sum());
            alert(arr2.sum());

            alert(arr1.sum == arr2.sum);

        </script>
    </head>
    <body>
        
    </body>
</html>